#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int N=105;
int a[N][N],n,m,rs[N],cs[N],x[N],y[N];
vector<int>row,col;
int r(int k){
	for(int j=1;j<=m;j++)a[k][j]*=-1,cs[j]+=a[k][j]*2;
	rs[k]*=-1;
	x[k]^=1;
	}
int c(int k){
	for(int i=1;i<=n;i++)a[i][k]*=-1,rs[i]+=a[i][k]*2;
	cs[k]*=-1;
	y[k]^=1;
	}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];	
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)rs[i]+=a[i][j],cs[j]+=a[i][j];
	
	int p=1;
	while(p){
		p=0;
		for(int i=1;i<=n;i++)if(rs[i]<0)r(i),p=1;
		for(int i=1;i<=m;i++)if(cs[i]<0)c(i),p=1;
		}
	for(int i=1;i<=n;i++)if(x[i])row.push_back(i);
	for(int j=1;j<=m;j++)if(y[j])col.push_back(j);
	
	cout<<row.size()<<" ";for(int i=0;i<row.size();i++)cout<<row[i]<<" ";cout<<endl;
	cout<<col.size()<<" ";for(int i=0;i<col.size();i++)cout<<col[i]<<" ";cout<<endl;
    return 0;
    }
